import { INDEX, toProjectDetail } from '@/utils';
import type { IColumnsOption } from 'vc';

export function useTable() {
  const columns = reactive<IColumnsOption[]>([
    { ...INDEX },
    {
      title: '项目名称',
      field: 'projectName',
      minWidth: 160,
      fixed: 'left',
      showOverflow: 'title'
    },
    {
      title: '项目详情',
      width: 110,
      align: 'center',
      slots: {
        default({ row }) {
          return row.id ? <a onClick={() => toProjectDetail(row.id)}>查看</a> : '-';
        }
      }
    },
    {
      title: '项目总投资额',
      field: 'totalInvestmentDisplay',
      width: 120,
      align: 'center',
      formatter({ row }) {
        return row.totalInvestmentDisplay ? row.totalInvestmentDisplay + '亿' : '-';
      }
    },
    {
      title: '项目资本金',
      width: 120,
      field: 'projectCapitalDisplay',
      align: 'center',
      formatter({ row }) {
        return row.projectCapitalDisplay ? row.projectCapitalDisplay + '亿' : '-';
      }
    },
    {
      title: '拟使用募集资金',
      width: 120,
      field: 'amountForProjectDisplay',
      align: 'center',
      formatter({ row }) {
        return row.amountForProjectDisplay ? row.amountForProjectDisplay + '亿' : '-';
      }
    },
    {
      title: '绿债融资金额',
      field: 'financingAmountGreenBondsDisplay',
      width: 120,
      align: 'center',
      formatter({ row }) {
        return row.financingAmountGreenBondsDisplay ? row.financingAmountGreenBondsDisplay + '亿' : '-';
      }
    },
    {
      title: '其他融资金额',
      field: 'financingAmountOthersDisplay',
      width: 120,
      align: 'center',
      formatter({ row }) {
        return row.financingAmountOthersDisplay ? row.financingAmountOthersDisplay + '亿' : '-';
      }
    },
    {
      title: '项目预测总收益',
      width: 120,
      field: 'forecastRevenueTotalDisplay',
      align: 'center',
      formatter({ row }) {
        return row.forecastRevenueTotalDisplay ? row.forecastRevenueTotalDisplay + '亿' : '-';
      }
    },
    {
      title: '建设起始年',
      width: 110,
      field: 'startingYear',
      align: 'center',
      formatter({ row }) {
        return row.startingYear ? row.startingYear + '年' : '-';
      }
    },
    {
      title: '建设截止年',
      width: 110,
      field: 'endYear',
      align: 'center',
      formatter({ row }) {
        return row.endYear ? row.endYear + '年' : '-';
      }
    },
    {
      title: '项目所属地区',
      minWidth: 120,
      field: 'areaName'
    }
  ]);

  return {
    columns
  };
}
